package org.example.controller;


import org.example.entity.Student;
import org.example.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 
 * @since 2024-06-18
 */
@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    IStudentService studentService;

    /**
     * 新增学生
     * @return
     */
    @PostMapping("/studentInser")
    public Map<String, String> studentInser(@RequestBody Student req) {
        System.out.println("req======"+req);
        boolean bool = studentService.save(req);
        if(bool){
            Map<String, String> map = new HashMap<>();
            map.put("success","true");
            return map;
        }else{
            Map<String, String> map = new HashMap<>();
            map.put("errorMsg","新增失败");
            return map;
        }
    }

    /**
     * 查询学生list
     * @return
     */
    @GetMapping("/studentInfolist")
    public List<Student> studentInfolist() {
        List<Student> list = studentService.list();
        return list;
    }
    /**
     * 查询学生
     * @return
     */
    public Map<String, String> studentInfo() {
        Map<String, String> map = new HashMap<>();
        map.put("success","true");
        return map;
    }

    /**
     * 修改学生
     * @return
     */
    public Map<String, String> studentUpdate() {
        Map<String, String> map = new HashMap<>();
        map.put("success","true");
        return map;
    }

    /**
     * 删除学生
     * @return
     */
    public Map<String, String> studentDelete() {
        Map<String, String> map = new HashMap<>();
        map.put("success","true");
        return map;
    }


}
